package com.solidumgame.locroninja.juego.ingredientes.choclo
{

	import com.solidumgame.locroninja.juego.Partida;
	import com.solidumgame.locroninja.juego.ingredientes.Ingrediente;
	import com.solidumgame.locroninja.juego.ingredientes.IngredienteCortado;
	
	import flash.geom.Vector3D;
	
	import libs.away3d.containers.ObjectContainer3D;
	import libs.away3d.core.base.Mesh;
	import libs.away3d.core.utils.Cast;
	import libs.away3d.loaders.Collada;
	import libs.away3d.materials.BitmapMaterial;
	import libs.away3d.materials.Material;
	import libs.away3d.materials.PhongBitmapMaterial;
	import libs.away3d.primitives.Cube;
	import libs.jiglib.geometry.JBox;
	import libs.jiglib.physics.RigidBody;
	import libs.jiglib.plugin.away3d.Away3dMesh;

	public class ChocloCortadoBot extends IngredienteCortado
	{
		
		[Embed(source="./assets/texturas/ingredientes/Choclo.jpg")] // MIME-type important!
		private static  var ChocloTextura : Class;
		
		[Embed(source="./assets/texturas/ingredientes/ChocloCortadoBot.dae",mimeType="application/octet-stream")] // MIME-type important!
		private static var ChocloMitadArribaDAE : Class;
		
		private static  var material:Material = new BitmapMaterial(Cast.bitmap(ChocloTextura));
		
		public function ChocloCortadoBot()
		{
			super();
			
			//Creamos cubo y le asignamos textura de choclo
			/*var cubo:Cube = new Cube({width:30,height:30,depth:30});
			for(var index:int = 0; index <= 3; index++){
				
				cubo.faces[index].material = Cast.material(texture_CornSide);
			} 
			
			for( index = 8; index <= 11; index++){
				
				cubo.faces[index].material = Cast.material(texture_CornSide);
			} 
			
			for( index = 4; index <= 5; index++){
				
				cubo.faces[index].material = Cast.material(texture_CornLeaf);
			} 
			
			for( index= 6; index <= 7; index++){
				
				cubo.faces[index].material = Cast.material(texture_CornUpper);
			} */
			
			
			var choclo:ObjectContainer3D = Collada.parse(ChocloMitadArribaDAE,{ autoLoadTextures:false}); 
			
			(choclo.children[0] as Mesh).material = material;
			
			
			_modelo3D.addChild(choclo);
		
			//Creamos modelo de fisica
			_modeloFisica =  new JBox(new Away3dMesh(_modelo3D),30,30,30);
			_id = _modeloFisica.id;
			_modeloFisica.collisionType = 1;
			
			_modeloFisica.setAngVel(new Vector3D(Math.random(),Math.random(),Math.random()));
			
			_valido = true;
			
		}
	}
}